import 'package:flutter_ahj_app/app/my/invoicing/HttpConfiguration/FP_APIConfiguration.dart';
import 'package:flutter_ahj_app/base/basewidget/HttpUtils/HttpClient.dart';

/// 发票请求接口
class FPHttpRequest {
  static Stream getPresetInvoice() {
    String url = FPAPIConfiguration.presetInvoice;
    return HttpClient.getInstance().get(url);
  }

  static Stream getSuppliertype({String supplierId}) {
    String url = FPAPIConfiguration.suppliertype;
    var params = {
      'supplierId': supplierId
    };
    return HttpClient.getInstance().get(url,params: params);
  }

  static Stream getInvoiceProject({int current, int size}) {
    String url = FPAPIConfiguration.invoiceProject;
    var params = {
      'current': current,
      'size': size ?? 15,
    };
    return HttpClient.getInstance().get(url, params: params);
  }

  static Stream postPresetInvoice({var params}) {
    String url = FPAPIConfiguration.postPresetInvoice;
    return HttpClient.getInstance().post(url, params);
  }

  static Stream deletePresetInvoiceId(int id) {
    String url = FPAPIConfiguration.deletePresetInvoiceId + id.toString();
    return HttpClient.getInstance().delete(url);
  }

  static Stream getPresetInvoiceId(int id) {
    String url = FPAPIConfiguration.getPresetInvoiceId + id.toString();
    return HttpClient.getInstance().get(url);
  }

  //获取发票历史
  static Stream getV1Invoice({int current, int size}) {
    var params = {
      'current': current,
      'size': size ?? 15,
    };
    String url = FPAPIConfiguration.getV1Invoice;
    return HttpClient.getInstance().get(url, params: params);
  }


  //发票申请作废
  static Stream getV1Invoicecancel(int id) {
    var params = {
      'id': id,
      'type': "1",
    };
    String url = FPAPIConfiguration.setV1Invoicecancel;
    return HttpClient.getInstance().get(url, params: params);
  }

  //获取默认预设发票信息
  static Stream getPresetInvoiceDefault() {
    String url = FPAPIConfiguration.getPresetInvoiceDefault;
    return HttpClient.getInstance().get(url);
  }

  //获取默认预设发票信息
  static Stream getKaiPiaoDetail(int id) {
    var params = {
      'id': id,
    };
    String url = FPAPIConfiguration.postV1Invoicedetails;
    return HttpClient.getInstance().get(url,params: params);
  }


  ///获取默认地址
  static Stream getPresetAddressDefault() {
    String url = FPAPIConfiguration.getPresetAddressDefault;
    return HttpClient.getInstance().get(url);
  }

  //获取我的地址列表
  static Stream getMineAdress() {
    String url = FPAPIConfiguration.getMineAdress;
    return HttpClient.getInstance().get(url);
  }

  //保存预设我的地址
  static Stream saveMyAdress(Map map) {
    String url = FPAPIConfiguration.getMineAdress;
    return HttpClient.getInstance().post(url, map);
  }

  //获取我的地址详情
  static Stream adressDetail(String id) {
    String url = FPAPIConfiguration.getMineAdress + '/' + id;
    return HttpClient.getInstance().get(url);
  }

  //删除预设地址
  static Stream deleteAdress(String id) {
    String url = FPAPIConfiguration.getMineAdress + '/' + id;
    return HttpClient.getInstance().delete(url);
  }

  /// 添加修改数据
  static Stream postV1Invoice(Map params) {
    var param = params;

    String url = FPAPIConfiguration.postV1Invoice;

    return HttpClient.getInstance().post(url, param);
  }
}
